{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Best similarity: 0.9852216748768473\n",
      "Best matching window:\n",
      "This is the first line of text B.\n",
      "This is the second line of text B.\n",
      "This is the third line of text B.\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "from autocoder.common.text import TextSimilarity\n",
    "# 示例文本A\n",
    "text_a = \"\"\"This is the first line of text A\n",
    "This is the second line of text B.\n",
    "This is the third line of text B.\"\"\"\n",
    "\n",
    "# 示例文本B\n",
    "text_b = \"\"\"Some other text that is not related.\n",
    "This is the first line of text B.\n",
    "This is the second line of text B.\n",
    "This is the third line of text B.\n",
    "Another unrelated line of text.\"\"\"\n",
    "\n",
    "# 创建TextSimilarity对象并找到相似度最高的窗口\n",
    "similarity_finder = TextSimilarity(text_a, text_b)\n",
    "best_similarity, best_window = similarity_finder.get_best_matching_window()\n",
    "print(\"Best similarity:\", best_similarity)\n",
    "print(\"Best matching window:\")\n",
    "print(best_window)\n",
    "\n",
    "print(best_window in text_b)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "byzerllm",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
